﻿#if WINDOWS
using ControlImpl = System.Windows.FrameworkElement;

#else


using ControlImpl = Avalonia.Controls.Control;

#endif

namespace KinonekoSoftware.Foundation.UI.Core
{
    public interface IViewLocator
    {
        /// <summary>
        /// 添加View与ViewModel之间的绑定信息
        /// </summary>
        /// <typeparam name="TView">View的类型</typeparam>
        /// <typeparam name="TViewModel">ViewModel的类型</typeparam>
        public void InstallView<TView, TViewModel>();


        /// <summary>
        /// 添加View与ViewModel之间的绑定信息
        /// </summary>
        /// <param name="tV">View的类型</param>
        /// <param name="tVM">ViewModel的类型</param>
        public void InstallView(Type tV, Type tVM);


        /// <summary>
        /// 添加View与ViewModel之间的绑定信息
        /// </summary>
        /// <param name="association">View与ViewModel之间的绑定信息</param>
        void InstallView(MVVMAssociation association);

        /// <summary>
        /// 关联视图和视图模型
        /// </summary>
        /// <param name="instance">可能是视图模型，也可能是视图</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">参数为空。</exception>
        /// <exception cref="ArgumentException">参数错误。</exception>
        public ControlImpl Associate(object instance);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="vm"></param>
        /// <typeparam name="TView"></typeparam>
        /// <typeparam name="TViewModel"></typeparam>
        /// <returns></returns>
        TView Associate<TView, TViewModel>(TViewModel vm) where TView : ControlImpl where TViewModel : IManagedLifetimeObject;

        IEnumerable<KeyValuePair<Type, MVVMAssociation>> Mappings          { get; }
        IEnumerable<Type>                                ViewModelMappings { get; }
        IEnumerable<Type>                                ViewMappings      { get; }
    }
}